<?php

/**
 * Agendado filter form base class.
 *
 * @package    cronos-doctrine
 * @subpackage filter
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormFilterGeneratedTemplate.php 29570 2010-05-21 14:49:47Z Kris.Wallsmith $
 */
abstract class BaseAgendadoFormFilter extends BaseFormFilterDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'empresa_id'            => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'parroquia_id'          => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Parroquia'), 'add_empty' => true)),
      'zona_id'               => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Zona'), 'add_empty' => true)),
      'servicio_tipo_id'      => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Categoria'), 'add_empty' => true)),
      'agendado_status_id'    => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('AgendadoStatus'), 'add_empty' => true)),
      'usuario_id'            => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Usuario'), 'add_empty' => true)),
      'agente_id'             => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('sfGuardUser'), 'add_empty' => true)),
      'camioneta_id'          => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Camioneta'), 'add_empty' => true)),
      'confirmacion_id'       => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Confirmacion'), 'add_empty' => true)),
      'descuento_id'          => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Descuento'), 'add_empty' => true)),
      'cantidad_mascota'      => new sfWidgetFormFilterInput(),
      'nota'                  => new sfWidgetFormFilterInput(),
      'cod_agendado'          => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'fecha_asig'            => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate(), 'with_empty' => false)),
      'duracion'              => new sfWidgetFormFilterInput(),
      'bitacora'              => new sfWidgetFormFilterInput(),
      'precio'                => new sfWidgetFormFilterInput(),
      'created_at'            => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate(), 'with_empty' => false)),
      'updated_at'            => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate(), 'with_empty' => false)),
      'llamada_servicio_list' => new sfWidgetFormDoctrineChoice(array('multiple' => true, 'model' => 'LlamadaServicio')),
    ));

    $this->setValidators(array(
      'empresa_id'            => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'parroquia_id'          => new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('Parroquia'), 'column' => 'id')),
      'zona_id'               => new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('Zona'), 'column' => 'id')),
      'servicio_tipo_id'      => new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('Categoria'), 'column' => 'id')),
      'agendado_status_id'    => new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('AgendadoStatus'), 'column' => 'id')),
      'usuario_id'            => new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('Usuario'), 'column' => 'id')),
      'agente_id'             => new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('sfGuardUser'), 'column' => 'id')),
      'camioneta_id'          => new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('Camioneta'), 'column' => 'id')),
      'confirmacion_id'       => new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('Confirmacion'), 'column' => 'id')),
      'descuento_id'          => new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('Descuento'), 'column' => 'id')),
      'cantidad_mascota'      => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'nota'                  => new sfValidatorPass(array('required' => false)),
      'cod_agendado'          => new sfValidatorPass(array('required' => false)),
      'fecha_asig'            => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 00:00:00')), 'to_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 23:59:59')))),
      'duracion'              => new sfValidatorPass(array('required' => false)),
      'bitacora'              => new sfValidatorPass(array('required' => false)),
      'precio'                => new sfValidatorSchemaFilter('text', new sfValidatorNumber(array('required' => false))),
      'created_at'            => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 00:00:00')), 'to_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 23:59:59')))),
      'updated_at'            => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 00:00:00')), 'to_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 23:59:59')))),
      'llamada_servicio_list' => new sfValidatorDoctrineChoice(array('multiple' => true, 'model' => 'LlamadaServicio', 'required' => false)),
    ));

    $this->widgetSchema->setNameFormat('agendado_filters[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function addLlamadaServicioListColumnQuery(Doctrine_Query $query, $field, $values)
  {
    if (!is_array($values))
    {
      $values = array($values);
    }

    if (!count($values))
    {
      return;
    }

    $query
      ->leftJoin($query->getRootAlias().'.AgendadoHasLlamadaServicio AgendadoHasLlamadaServicio')
      ->andWhereIn('AgendadoHasLlamadaServicio.llamada_servicio_id', $values)
    ;
  }

  public function getModelName()
  {
    return 'Agendado';
  }

  public function getFields()
  {
    return array(
      'id'                    => 'Number',
      'empresa_id'            => 'Number',
      'parroquia_id'          => 'ForeignKey',
      'zona_id'               => 'ForeignKey',
      'servicio_tipo_id'      => 'ForeignKey',
      'agendado_status_id'    => 'ForeignKey',
      'usuario_id'            => 'ForeignKey',
      'agente_id'             => 'ForeignKey',
      'camioneta_id'          => 'ForeignKey',
      'confirmacion_id'       => 'ForeignKey',
      'descuento_id'          => 'ForeignKey',
      'cantidad_mascota'      => 'Number',
      'nota'                  => 'Text',
      'cod_agendado'          => 'Text',
      'fecha_asig'            => 'Date',
      'duracion'              => 'Text',
      'bitacora'              => 'Text',
      'precio'                => 'Number',
      'created_at'            => 'Date',
      'updated_at'            => 'Date',
      'llamada_servicio_list' => 'ManyKey',
    );
  }
}
